#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START cmake-native

save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
export CFLAGS='-O2 -g'
unset CPPFLAGS
unset LDFLAGS

# build a temporary native cmake
rm -rf build/cmake-native
mkdir -p build/cmake-native
cd build/cmake-native
../../cmake/bootstrap \
	--verbose \
	--parallel=${JOBS} \
	--no-system-libs \
	--prefix=${build_prefix}

cd ../..
make_native_build build/cmake-native

export CFLAGS="$save_CFLAGS"
export CPPFLAGS="$save_CPPFLAGS"
export LDFLAGS="$save_LDFLAGS"

# RECIPE END cmake-native
